<template>
  <ContentWrap>
    <!-- 搜索工作栏 -->
    <el-form
      class="-mb-15px"
      :model="queryParams"
      ref="queryFormRef"
      :inline="true"
      label-width="100px"
    >

      <el-form-item label="产品编号" prop="productCode">
        <el-input
          v-model="queryParams.productCode"
          placeholder="请输入产品编号"
          clearable
          class="!w-240px"
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="内码" prop="internalCode">
        <el-input
          v-model="queryParams.internalCode"
          placeholder="请输入内码"
          clearable
          class="!w-240px"
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单编号" prop="orderCode">
        <el-input
          v-model="queryParams.orderCode"
          placeholder="请输入订单编号"
          clearable
          class="!w-240px"
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="称重日期" prop="dateReq">
        <el-date-picker
          v-model="queryParams.dateReq"
          value-format="YYYY-MM-DD HH:mm:ss"
          type="datetimerange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          class="!w-400px"
        />
      </el-form-item>
      <el-form-item>
        <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
        <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
      </el-form-item>
    </el-form>
  </ContentWrap>
  <!-- 列表 -->
  <ContentWrap>
    <el-table v-loading="loading" :data="list">
      <el-table-column type="index" label="序号" align="center" width="55" />
      <el-table-column label="产品编号" align="center" prop="productCode" />
      <el-table-column label="订单编号" align="center" prop="orderCode" />
      <el-table-column label="成品型号" align="center" prop="type" />
      <!-- <el-table-column label="织板编码" align="center" prop="materialCode" /> -->
      <el-table-column label="箱码" align="center" prop="batchCode" />
      <el-table-column label="内码" align="center" prop="internalCode" />
      <el-table-column label="一次重量 " align="center" prop="weightTest" />
      <el-table-column label="刚性测试结果 " align="center" prop="rigidity" />
      <el-table-column label="平衡测试结果 " align="center" prop="balance" />
      <el-table-column label="二次平衡测试结果 " align="center" prop="balanceTwice" />
      <el-table-column label="成品重量 " align="center" prop="weight" />
      <el-table-column label="操作" align="center" width="160">
        <template #default="scope">
          <div class="flex items-center justify-center">
            <el-button
              type="primary"
              link
              @click="openEditForm(scope.row.productCode)"
              v-hasPermi="['project:production-code:updateProductionCodeKey']"
            >编辑
            </el-button>
          </div>
        </template>
      </el-table-column>

    </el-table>
    <!-- 分页 -->
    <Pagination
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </ContentWrap>

  <RigidForm ref="formRef" @success="getList" />
</template>

<script lang="ts" setup>
import * as RigidReportApi from '@/api/hcxly/RigidReport/Index'
import RigidForm from './RigidForm.vue'

defineOptions({ name: 'RigidReport' })

const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化

const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据

const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  materialCode: '',
  productCode: '',
  internalCode: '',
  dateReq: [],
  orderNo:''
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const data = await RigidReportApi.getRigidReport(queryParams)
    console.log(data)
    list.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.pageNo = 1
  getList()
}

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value.resetFields()
  handleQuery()
}
const formRef = ref()
const openEditForm = (productCode?: string) => {
  formRef.value.open(productCode)
}

/** 初始化 **/
onMounted(() => {
  getList()
})

</script>
